//
// Created on 2025/10/31.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#include <multimedia/player_framework/native_avscreen_capture.h>
#include <multimedia/player_framework/native_avscreen_capture_base.h>
#include <multimedia/player_framework/native_avbuffer.h>
#include "hilog/log.h"
#include <string>
#include "multimedia/player_framework/native_avcodec_videodecoder.h"
#include "multimedia/player_framework/native_avcodec_videoencoder.h"
#include <multimedia/player_framework/native_avcapability.h>
#include <multimedia/player_framework/native_avcodec_base.h>
#include <multimedia/player_framework/native_avbuffer.h>


#ifndef MEDIA_UTILS_SCREENRECORDER_H
#define MEDIA_UTILS_SCREENRECORDER_H

class ScreenRecorder {
public:
    static ScreenRecorder& instance(); // 单例

    // 控制
    int startScreenCapture(std::string& configStr,bool isMicrophone);
    int stopScreenCapture();
    ~ScreenRecorder();


private:
    ScreenRecorder() = default;
    struct OH_AVScreenCapture *g_avCapture ={};
    OH_AVScreenCaptureConfig config_;
    static void OnError(OH_AVScreenCapture *capture, int32_t errorCode, void *userData);
    static void OnBufferAvailable(OH_AVScreenCapture *capture, OH_AVBuffer *buffer, OH_AVScreenCaptureBufferType bufferType,
                           int64_t timestamp, void *userData);
    static void OnDisplaySelected(struct OH_AVScreenCapture *capture, uint64_t displayId, void *userData);
    static void OnStateChange(struct OH_AVScreenCapture *capture, OH_AVScreenCaptureStateCode stateCode, void *userData);
    
    static bool isRunning;

};

#endif //MEDIA_UTILS_SCREENRECORDER_H
